package test;

import jakarta.persistence.Query;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lei
 * @create 2025-05-22 11:22
 */
public class sql {
    public static void main(String[] args) {
        StringBuffer sql = new StringBuffer();
        List<Object> params = new ArrayList<>();
        sql.append(" SELECT  ");
        sql.append("         distinct m.menu_id menuId, m.parent_id parentId, m.menu_name menuName, m.path path, m.component component, m.visible visible, m.status status ");
        sql.append("       , ifnull(m.perms,'') as perms, m.is_frame isFrame, m.is_cache isCache, m.menu_type menuType, m.icon icon, m.order_num orderNum");
        sql.append("       , m.create_by createBy,m.create_time createTime ,m.update_by updateBy,m.update_time updateTime,m.remark remark ");
        sql.append(" FROM sys_menu m ");
        sql.append(" LEFT join sys_role_menu rm on m.menu_id = rm.menu_id ");
        sql.append(" LEFT join sys_user_role ur on rm.role_id = ur.role_id ");
        sql.append(" LEFT join sys_role ro on ur.role_id = ro.role_id ");
        sql.append(" WHERE ur.user_id = ?  ");
  /*      params.add(menu.getParams().get("userId"));
        if (StringUtils.isNotBlank("zhans")) {
            sql.append(" AND menu_name like ? ");
            params.add("%" + menu.getMenuName() + "%");
        }
        if (StringUtils.isNotBlank(menu.getVisible())) {
            sql.append(" AND visible = ? ");
            params.add(menu.getVisible());
        }
        if (StringUtils.isNotBlank(menu.getStatus())) {
            sql.append(" AND status = ? ");
            params.add(menu.getStatus());
        }
        sql.append(" order by m.parent_id, m.order_num ");
   */

        System.out.println(sql);
    }
}
